/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package view;

import java.awt.event.ActionListener;
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JTextField;
import javax.swing.JToolBar;

/**
 *
 * @author Luci
 */
public class MyToolBar extends JToolBar{
    private JButton createGroup = createButton("Image\\add-group.jpg","create a new task group");
    private JButton createTask = createButton("Image\\add-task.png","create a new task");
    private JButton sort1 = createButton("Image\\sort-icon1.png","Sort by Time");
    private JButton sort2 = createButton("Image\\sort-icon2.jpg","Sort by Status");
    public JTextField tf1 = new JTextField(12) ;
    private JButton filter1 = createButton("Image\\filter-icon1.jpg","Filter by Name");
    public JComboBox cb1 = new JComboBox();
    private JButton filter2 = createButton("Image\\filter-icon2.jpg","Filter by Priority");
    private JButton complete= createButton("Image\\complete.jpg","Complete a task");
    private JButton modify = createButton("Image\\modify.png","Modify a task");
    private JButton delete = createButton("Image\\delete.png","Delete a Task");
    public MyToolBar(){
        super();
        setFloatable(false);
        add(createGroup);
        
        add(createTask);
        addSeparator();
        add(sort1);
        add(sort2);

        add(tf1);
        add(filter1);
        
        cb1.addItem("Normal");
        cb1.addItem("High");
        add(cb1);
        add(filter2);
        
        addSeparator();
        add(complete);
        add(modify);
        add(delete);
    }
    private JButton createButton(String icon, String description){
        JButton bt = new JButton();
        bt.setSize(38, 38);
        bt.setIcon( new ImageIcon(icon));
        bt.setToolTipText(description);
        
        
        //bt.setBorder(BorderFactory.createEmptyBorder());
        return bt;
    }
    public void setDescription(boolean l){
        if(l){
            createTask.setToolTipText("Tạo mới một nhiệm vụ");
            createGroup.setToolTipText("Tạo mới một nhóm nhiệm vụ");
            sort1.setToolTipText("Sắp xếp theo thời gian");
            sort2.setToolTipText("Sắp xếp theo trạng thái");
            filter1.setToolTipText("Lọc theo từ khóa");
            filter2.setToolTipText("Lọc theo độ ưu tiên");
            complete.setToolTipText("Hoàn thành một nhiệm vụ");
            modify.setToolTipText("Chỉnh sửa một nhiệm vụ");
            delete.setToolTipText("Xóa một nhiệm vụ");
            cb1.removeAllItems();
            cb1.addItem("Thường");
            cb1.addItem("Cao");
        }else{
            
        }   
    }
    public void addEventSortStatus(ActionListener e){
        sort2.addActionListener(e);
    }
    public void addEventSortTime(ActionListener e){
        sort1.addActionListener(e);
    }
    public void addEventFilterName(ActionListener e){
        filter1.addActionListener(e);
    }
    public void addEventFilterPriority(ActionListener e){
        filter2.addActionListener(e);
    }
    public void addEventComplete(ActionListener e){
        complete.addActionListener(e);
    }
    public void addEventModify(ActionListener e){
        modify.addActionListener(e);
    }
    public void addEventDelete(ActionListener e){
        delete.addActionListener(e);
    }
    public void addEventCreateGroup(ActionListener e){
        createGroup.addActionListener(e);
    }
    public void addEventCreateTask(ActionListener e){
        createTask.addActionListener(e);
    }

}
